package leetcode


//https://leetcode.com/problems/valid-palindrome/
fun main(args: Array<String>) {
    println(ValidPalindrome().isPalindrome("A man, a plan, a canal: Panama"))
}

class ValidPalindrome {

    fun isPalindrome(s: String): Boolean {
       val str =  s.toUpperCase()
        println(s)
        var i = 0
        var j = str.length - 1
        while (i < j) {
            if ((str[i] in '0'..'9' || str[i] in 'A'..'Z'))
                if ((str[j] in '0'..'9' || str[j] in 'A'..'Z')) {
                    if (str[i] != str[j]) {
                        println(str[i].toString() + str[j].toString())
                        return false
                    } else {
                        i++
                        j--
                    }
                } else j--
            else i++
        }

        return true
    }
}